package com.project.ServiceImp;


import com.Entity.DzmPatientEntity;
import com.alibaba.dubbo.config.annotation.Service;
import com.project.mapper.PatientDao;
import gz.PatientService;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service(interfaceClass = PatientService.class)
@Component
@Transactional
public class PatientServiceImp implements PatientService {


    @Resource
    private PatientDao pd;


    //根据患者id进行批量删除
    @Override
    public int deletes_patient(String[] patient_id) {
        int i =  pd.deletes_patient(Arrays.asList(patient_id));
        return i;
    }



    //查询出所有处于移除状态的患者
    @Override
    public List<DzmPatientEntity> allMove(String names) {
        Map map = new HashMap<String,Object>();
        map.put("names",names);
        return pd.allMove(map);
    }



    //计算移除的人数
    @Override
    public int movePerson() {
        int i = pd.movePerson();
        System.out.println("移除的人数："+i);
        return i;
    }


    //根据获取的id修改该患者的状态为移除
    @Override
    public int moveId(Integer id) {
        return pd.moveId(id);
    }

    //查询所有患者
    @Override
    public List<DzmPatientEntity> findAll(String name,String mobile) {
        Map map = new HashMap<String,Object>();
        map.put("name",name);
        map.put("mobile",mobile);
        List<DzmPatientEntity> all = pd.findAll(map);
        System.out.println(all+"[][][][][][");
        return all;
    }

    //根据选择的患者id进行批量恢复
    @Override
    public int recover_patient(String[] patient_id) {
        int i = pd. recover_patient(Arrays.asList(patient_id));
        return i;
    }


    //选中某患者获取数据
    @Override
    public List<Map<String, Object>> getOne(Integer patient_id) {
        return pd.getOne(patient_id);
    }


    //重新编辑数据进行修改（dzm_patient表）
    @Override
    public int update_patient(Map<String, Object> map) {
        int i = pd.update_patient(map);
        return i;
    }

    //对dzm_his_patient_file进行修改
    @Override
    public int update_file(Map<String, Object> map) {
        int s = pd.update_file(map);
        return s;
    }


    /**
     * 获取患者信息
     * @param patient_id
     * @return
     */
    @Override
    public List<Map<String, Object>> getOnes(Integer patient_id) {
        return pd.getOnes(patient_id);
    }


    /**
     * 新增信息到patient_file表
     * @param map
     * @return
     */
    @Override
    public int insert_patientFile(Map<String, Object> map) {
        int a = pd.insert_patientFile(map);
        return a;
    }

    //新增信息到file表中
    @Override
    public int insert_file(Map<String, Object> map) {
        int i = pd.insert_file(map);
        return i;
    }
}
